package com.sctvcloud.qingchuan.ui.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.ruihang.generalibrary.ui.adapter.BaseHolderAbsAdapter;
import com.sctvcloud.qingchuan.R;
import com.sctvcloud.qingchuan.ui.adapter.holder.BaseAbsHolder;
import com.sctvcloud.qingchuan.ui.adapter.holder.MyAttentionHolder;
import com.sctvcloud.qingchuan.ui.util.IListShowData;

import java.util.List;

/**
 * 关注的公众号
 */
public class MyAttentionAdapter extends BaseHolderAbsAdapter<IListShowData, BaseAbsHolder<IListShowData>> {


    private Context context;
    private MyAttentionHolder.OnAttentionItemClickListener itemClickListener;
    public MyAttentionAdapter(Context context, List<IListShowData> list, MyAttentionHolder.OnAttentionItemClickListener itemClickListener) {
        super(context, list);
        this.context = context;
        this.itemClickListener = itemClickListener;
    }


    @Override
    public BaseAbsHolder<IListShowData> onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(context).inflate(R.layout.item_account_attention, parent, false);
        BaseAbsHolder holder = new MyAttentionHolder(context, view,itemClickListener);
        return holder;
    }


    public void addData(List<IListShowData> list) {
        int pos = getItemCount();
        if (null != list) {
            data.addAll(list);
        }
        if (pos > 0) {
            notifyItemRangeChanged(pos, getItemCount());
        }
    }



    @Override
    public int getItemViewType(int position) {
        return 0;//dataList.get(position).getDataViewType();
    }

    @Override
    public void onBindViewHolder(BaseAbsHolder<IListShowData> holder, int position) {
        super.onBindViewHolder(holder, position);
    }

//
//    @Override
//    public int getItemCount() {
//        return data.size();
//    }

    public interface OnAttentionClickListener {
        void OnAttentionClick(int position);
    }
}
